//
//  UIViewController+LCLoadData.m
//  JKFuYinProject
//
//  Created by admin on 2018/7/24.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "UIViewController+LCLoadData.h"
#import "NetworkTool.h"
#import "LCFuYinIncomes.h"

//#define NetworkToolGET [[NetworkTool sharedInstance] POSTFuYinWithUrlString:urlString input:parameters success:^(NSDictionary *dict) {\
//if (successBlock) {\
//successBlock(dict);\
//}\
//} failure:^(NSError *error) {\
//if (failureBlock) {\
//failureBlock(error);\
//}\
//}];

#define NetworkToolPOST [[NetworkTool sharedInstance] POSTFuYinWithUrlString:urlString input:parameters success:^(NSDictionary *dict) {\
if (successBlock) {\
successBlock(dict);\
}\
} failure:^(NSError *error) {\
if (failureBlock) {\
failureBlock(error);\
}\
}];

@implementation LCViewController (LCLoadData)

///剩余阅读领取的福音值次数 lingNumber
- (void)PostLingNumberWithType:(NSString *)type action:(NSString *)action tid:(NSString *)tid success:(void (^)(NSDictionary *))successBlock failure:(void (^)(NSError *))failureBlock {
    
    NSString *urlString = [NSString stringWithFormat:@"%@%@"
                           ,http_toutiao,@"/task/fuyin"
                           ];
    if (1) {
        NSLog(@"urlString = %@", urlString);
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{@"type":type,@"action":action}];
    if (tid == nil) {
    }else{
        [parameters setObject:tid forKey:@"tid"];
    }
    NetworkToolPOST;
}

- (void)loadLCBeautifulEssayControllerLingNumberDataWithSuccess:(void (^)(NSDictionary *))successBlock failure:(void (^)(NSError *))failureBlock  {
    
    NSString *urlString = [NSString stringWithFormat:@"%@%@"
                           ,http_zongSJUrl,@"/article/score_log"
                           ];
    if (1) {
        NSLog(@"urlString = %@", urlString);
    }
    NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{}];
    
    NetworkToolPOST;
    
    
    /**[self PostLingNumberWithType:@"32" action:@"1" tid:nil success:^(NSDictionary *dict) {
     NSLog(@"dict = %@", dict);
     NetWorkModel *netWorkModel = [NetWorkModel yy_modelWithJSON:dict];
     if (netWorkModel.status == 1) {
     NSDictionary *dic = netWorkModel.data;//dic
     LCFuYinIncomes *fuYinIncomes = [LCFuYinIncomes yy_modelWithJSON:dic];
     NSLog(@"fuYinIncomes.limit = %zd", fuYinIncomes.limit);
     [[NSNotificationCenter defaultCenter] postNotificationName:@"LCFuYinIncomesDidChangedNotification" object:self userInfo:@{@"limit":[NSString stringWithFormat:@"%zd",fuYinIncomes.limit]}];
     }else if (netWorkModel.status == 2) {
     [[NSNotificationCenter defaultCenter] postNotificationName:@"LCFuYinIncomesDidChangedNotification" object:self userInfo:@{@"limit":[NSString stringWithFormat:@"%d",200]}];
     }
     } failure:^(NSError *error) {
     NSLog(@"error = %@", error);
     }];*/
}

- (void)lcLingBeautifulEssayIncomesDataWithTid:(NSString *)tid action:(NSString *)action{
    [self PostLingNumberWithType:@"32" action:action tid:tid success:^(NSDictionary *dict) {
        NSLog(@"dict = %@", dict);
        NetWorkModel *netWorkModel = [NetWorkModel yy_modelWithJSON:dict];
        if (netWorkModel.status == 1) {
            NSDictionary *dic = netWorkModel.data;//dic
            LCFuYinIncomes *fuYinIncomes = [LCFuYinIncomes yy_modelWithJSON:dic];
            [self showHud3WithTitle:[NSString stringWithFormat:@"%@",fuYinIncomes.title] :fuYinIncomes.tip];
        }
        //        else if(netWorkModel.status == 0){
        //            [self showHud3WithTitle:[NSString stringWithFormat:@"%@",netWorkModel.msg] :@""];
        //        }
        else{
            if ([action isEqualToString:@"6"]) {
                [SVProgressHUD showSuccessWithStatus:@"评论成功!"];
                [SVProgressHUD dismissWithDelay:1];
            }
        }

    } failure:^(NSError *error) {
        NSLog(@"error = %@", error);
    }];
}

///评论得福音值
- (void)addLCBeautifulEssayControllerLingCommentsIncomesDataWithTid:(NSString *)tid
{
    [self lcLingBeautifulEssayIncomesDataWithTid:tid action:@"6"];
}
///分享得福音值  没登录服务器端有判断
- (void)addLCBeautifulEssayControllerLingShareIncomesDataWithTid:(NSString *)tid
{
    [self lcLingBeautifulEssayIncomesDataWithTid:tid action:@"4"];
}



@end
